package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: ProjectLogServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-11-14
 * @Version: 1.0
 * Table: pear_project_log
 * Comment:
 * 项目日志表
 */
@Service
public class ProjectLogServiceImpl extends ProjectLogServiceCustomImpl implements ProjectLogService {

    static {
        beanClassNameMap.put("project_log", "projectLogServiceImpl");
        listMethodNameMap.put("project_log", "listProjectLog");
        listMethodParameterClassNameMap.put("project_log", "ProjectLogQueryRequest");
        updateMethodNameMap.put("project_log", "updateProjectLog");
        updateMethodParameterClassNameMap.put("project_log", "ProjectLogUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addProjectLog(ProjectLogAddRequest request) throws Exception {
        super.fixRequest("project_log", "add", request);
        return super.addProjectLog(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateProjectLog(ProjectLogUpdateRequest request) throws Exception {
        ProjectLog record = null;
        record = projectLogMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("project_log", "update", request, record);
        return super.updateProjectLog(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteProjectLog(ProjectLogDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<ProjectLog> list = null;
            ProjectLogExample example = new ProjectLogExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = projectLogMapper.selectByExample(example);
            fixRequest("project_log", "delete", request, list);
        } else {
            fixRequest("project_log", "delete", request);
        }
        return super.deleteProjectLog(request);
    }

    @Override
    public ProjectLogQueryResponse queryProjectLog(ProjectLogQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        ProjectLogQueryResponse result = super.queryProjectLog(request);
        checkResult("project_log", "query", request, result);
        return result;
    }

    @Override
    public List<ProjectLogQueryResponse> listProjectLog(ProjectLogQueryRequest request) throws Exception {
        List<ProjectLogQueryResponse> list = super.listProjectLog(request);
        checkResult("project_log", "list", request, list);
        return list;
    }

    @Override
    public Integer countProjectLog(ProjectLogQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_log", "count", request);
        return super.countProjectLog(request);
    }

    @Override
    public BaseStatResponse statProjectLog(ProjectLogQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_log", "stat", request);
        return super.statProjectLog(request);
    }

}
